﻿<!DOCTYPE HTML>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="renderer" content="webkit|ie-comp|ie-stand">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		<link href="../static/h-ui/css/H-ui.min.css" rel="stylesheet" type="text/css" />
		<link href="../static/h-ui.admin/css/H-ui.login.css" rel="stylesheet" type="text/css" />
		<link href="../static/h-ui.admin/css/style.css" rel="stylesheet" type="text/css" />
		<link href="../lib/Hui-iconfont/1.0.8/iconfont.css" rel="stylesheet" type="text/css" />
		<title>kvm-后台管理系统</title>
		<meta name="keywords" content="">
		<meta name="description" content="">
	</head>

	<body>
		<input type="hidden" id="TenantId" name="TenantId" value="" />
		<div class="loginWraper my_bg">
			<div id="loginform" class="loginBox my_drag">
				<h3 style="text-align: center;padding-top: 5px;">KVM后台管理系统</h3>
				<div class="form form-horizontal">
					<div class="row cl">
						<label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60d;</i></label>
						<div class="formControls col-xs-8">
							<input id="loginName" name="" type="text" placeholder="账户" class="input-text size-L">
						</div>
					</div>
					<div class="row cl">
						<label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60e;</i></label>
						<div class="formControls col-xs-8">
							<input id="userPassword" name="" type="password" placeholder="密码" class="input-text size-L">
						</div>
					</div>
					<div class="row cl">
						<div class="formControls col-xs-8 col-xs-offset-3">
							<input class="input-text size-L" id="vfCode" type="text" placeholder="验证码" style="width:240px;">
							<img id="yanzhengm" style="width:115px;height:41px;cursor: pointer;">
						</div>
					</div>
					<div class="row cl">
						<div class="formControls col-xs-8 col-xs-offset-5">
							<input name="" type="submit" class="btn btn-success radius size-L" value="&nbsp;登&nbsp;&nbsp;&nbsp;&nbsp;录&nbsp;">
						</div>
					</div>
				</div>
			</div>
		</div>

		<script type="text/javascript" src="../lib/jquery/1.9.1/jquery.min.js"></script>
		<script type="text/javascript" src="../static/h-ui/js/H-ui.min.js"></script>
		<script type="text/javascript" src="../lib/layer/2.4/layer.js"></script>
		<script type="text/javascript" src="../static/js/common.js"></script>

		<script type="text/javascript">
			$(function() {
				$("#yanzhengm").attr("src", admin_url + "/scaSysUser/vfcode?flag=");
				//enter事件
				document.onkeydown = function(e) {
					var ev = document.all ? window.event : e;
					if(ev.keyCode == 13) {
						$(".radius").click();
					}
				};
			})
			$("#yanzhengm").click(function() {
				$("#yanzhengm").attr("src", admin_url + "/scaSysUser/vfcode?flag=" + Math.random());
			});
			$(".radius").click(function() {
				var loginName = $("#loginName").val(); //获取用户名
				var userPassword = $("#userPassword").val(); //获取用户名
				var vfCode = $("#vfCode").val(); //获取验证码
				//用户名不能为空
				if(loginName == "" || loginName == null) {
					layer.msg("请输入用户名！", {
						icon: 5,
						time: 1500
					});
				}
				//密码不能为空
				if(userPassword == "" || userPassword == null) {
					layer.msg("请输入密码！", {
						icon: 5,
						time: 1500
					});
				}
				//验证码不能为空
				if(vfCode == "" || vfCode == null) {
					layer.msg("请输入验证码！", {
						icon: 5,
						time: 1500
					});
				}

				var data = {
					"vfCode": vfCode,
					"userName": loginName,
					"loginPassword": userPassword
				};
				request_ajax("POST", admin_url + "/scaSysUser/sysUserLogin", data, function(result) {
					layer.msg(result.msg, {
						time: 800,
						end: function() {
							if(result.code == 603 || result.code == 606) { //重置验证码，密码
								$("#yanzhengm").attr("src", admin_url + "/scaSysUser/vfcode?flag=" + Math.random());
								$("#userPassword").val("");
							} else if(result.code == 604) { //重置验证码
								$("#yanzhengm").attr("src", admin_url + "/scaSysUser/vfcode?flag=" + Math.random());
							} else if(result.code == 605) { //重置所有
								$("#loginName").val("");
								$("#yanzhengm").attr("src", admin_url + "/scaSysUser/vfcode?flag=" + Math.random());
								$("#userPassword").val("");
							} else if(result.code == 607 || result.code == 602) { //停留
								window.location.reload();
							} else if(result.code == 601 || result.code == 608) { //登录成功跳转页面
								sessionStorage.setItem(pj_name + "-token", result.data.token);
								sessionStorage.setItem(pj_name + "-suser", JSON.stringify(result.data.suser));
								window.location.href = "../index/index.html";
							}
						}
					});
				});
			});
		</script>
	</body>

</html>